package br.jcrsistemas.factory;

import br.jcrsistemas.database.TipoBanco;
import br.jcrsistemas.util.Configuracoes;
import br.jcrsistemas.util.SysException;
import java.sql.Connection;
import java.sql.ResultSet;
import java.sql.SQLException;


public abstract class ConnFactory {
	public TipoBanco tipoBanco;
	
	public abstract String     getClassName();
	public abstract void       commit() throws SysException;
	public abstract void       rollback() throws SysException;
	public abstract String getLastInsertIDQuery(String tabela, String campo);
	public abstract ResultSet executeSelectQuery(String query) throws SQLException, ClassNotFoundException;
	public abstract void desconecta() throws SQLException;
	public abstract Connection abreConexao() throws SQLException;
	
	public static ConnFactory getConnectionFactory() {
		switch ( Configuracoes.getTipoBanco() ) {
		case POSTGRESQL:
			return new PostgresConnFactory();
		default:
			return null;
		}
	}
	
	
}
